package com.easy.config;


import com.easy.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName InterceptorConfiguration
 * @Description TODO 相关配置类
 * @Author 周轩霆
 * @Date 2022/5/30 9:21
 **/
@Configuration
public class InterceptorConfiguration extends WebMvcConfigurerAdapter {


    //交给Spring管理
    @Bean
    public LoginInterceptor getLoginInterceptor() {

        //将方法的返回值作为Bean对象
        return new LoginInterceptor();

    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        List<String> list = new ArrayList();
        //配置拦截路径
        list.add("/staff/*");
        list.add("/vip/*");
        list.add("/room/*");
        list.add("/page/*");
        list.add("/order/*");
        registry.addInterceptor(getLoginInterceptor()).addPathPatterns(list);


    }
}

